const path = require('path')
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin');
const htmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
    entry: './src/main.js',
    output: {
        filename: '[name]-[hash].bundle.js',
        path: path.join(__dirname, 'dist'),
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                use: 'vue-loader',
            },
            {
                test: /\.(png|jpg|jpeg)$/,
                use: {
                    loader: 'url-loader',
                    options: {
                        esModule: false,
                        limit: 10 * 1024
                    }
                }
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            BASE_URL: "'/'"
        }),
        new CopyPlugin({
            patterns: [
                {
                    from: path.join(__dirname, 'public'),
                    globOptions:{
                        ignore: ['*.html']
                    },
                    to: path.join(__dirname, 'dist'),
                }
            ]
        }),
        new VueLoaderPlugin(),
        new htmlWebpackPlugin({
            title: 'Test',
            template: './public/index.html'
        }) 
    ]
}